package test.luin.pers.myapplication;

import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class Broadcast extends AppCompatActivity {

    private MyReceiver myReceiver;
    private IntentFilter intentFilter;

    private  BroadcastOne broadcastOne;
    private  BroadcastTwo broadcastTwo;
    private  BroadcastThree broadcastThree;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_broadcast);
//        myReceiver = new MyReceiver();
//        intentFilter = new IntentFilter();
//        intentFilter.addAction("cn.edu.jzsz.Help");
//        registerReceiver(myReceiver,intentFilter);
        broadcastOne = new BroadcastOne();
        broadcastTwo = new BroadcastTwo();
        broadcastThree = new BroadcastThree();
        intentFilter = new IntentFilter();
        intentFilter.addAction("cn.edu.jzsz.Help");
        intentFilter.setPriority(1000);
        registerReceiver(broadcastOne,intentFilter);
        intentFilter.setPriority(300);
        registerReceiver(broadcastTwo,intentFilter);
        intentFilter.setPriority(600);
        registerReceiver(broadcastThree,intentFilter);
    }



    public void send(View view) {
        Intent intent = new Intent();
        //定义广播的事件类型
        intent.setAction("cn.edu.jzsz.Help");

        //发送广播
//       sendOrderedBroadcast(intent,null);
       sendOrderedBroadcast(intent,null,broadcastTwo,null,0,null,null);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        unregisterReceiver(broadcastOne);
        unregisterReceiver(broadcastTwo);
        unregisterReceiver(broadcastThree);
    }
}
